import Vue from "vue";
import JsEncrypt from "jsencrypt/bin/jsencrypt";

Vue.prototype.JsEncrypt = function(pwd) {
  let jse = new JsEncrypt.JSEncrypt();
  jse.setPublicKey(`-----BEGIN PUBLIC KEY-----
  MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCNreemc+C+H8S/awLprNL3QRql/vNwjizeuPawiBg7OYD/oVu1RTfqx+AC2JXcfo2uJyPWnMCx/oiLzns4xWFY5O76aIsPXC+wksILCjRYxYwxf8WGjoS2UO4sGmDLD+epTM8PvwzLNXz5Ftx50cYAU5o8U7x3VXmP8+o75EDJHQIDAQAB
  -----END PUBLIC KEY-----`);
  // 设置需要加密的字符串
  let encrypted = jse.encrypt(pwd);
  // 输出加密结果
  return encrypted

//   // 设置密钥
//   jse.setPrivateKey(`-----BEGIN RSA PRIVATE KEY-----
//   
// -----END RSA PRIVATE KEY-----`);
//   // 解密加密过的字符串
//   let decrypted = jse.decrypt(encrypted);
//   // 打印结果
//   console.log(decrypted);
};
